/**
 *  StaDiUM - State Diagram Unified Modeler
 *  Copyright (C) 2007  Stefan Bucur, Mihai Balan, Claudiu Tanase
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.

 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.

 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

/**
 *  File Information
 *
 *  Last Modified On: $Date: 2007-06-03 18:26:23 +0000 (Sun, 03 Jun 2007) $
 *  Last Modified By: $Author: stefan.bucur $
 */

package ro.pub.cs.stadium.document;

import java.util.Hashtable;
import java.util.Map;


/**
 * Provides basic functionality to a diagram document
 * @author stefan
 *
 */
public abstract class AbstractDocument implements IDocument {
	
	private Map<String, IState> states = null;
	private Map<String, ITransition> transitions = null;
	
	private MeasureUnit xUnit = null;
	private MeasureUnit yUnit = null;
	
	private Point viewPosition = null;
	
	private Size documentSize = null;
	
	private float zoom = 0.0f;

	public AbstractDocument() {
		states = new Hashtable<String, IState>();
		transitions = new Hashtable<String, ITransition>();
		
		xUnit = MeasureUnit.CENTIMETERS;
		yUnit = MeasureUnit.CENTIMETERS;
		
		viewPosition = new Point(0.0f, 0.0f);
		
		documentSize = new Size(21.0f, 29.7f); // A4 paper format
		
		zoom = 1.0f; // 100 %
	}

	/**
	 * Returns the list of states in the diagram document
	 */
	public Map<String, IState> getStates() {
		return states;
	}

	/**
	 * Returns the list of transitions in the diagram document
	 */
	public Map<String, ITransition> getTransitions() {
		return transitions;
	}

	/**
	 * Returns the unit of measure on the X axis
	 */
	public MeasureUnit getXUnit() {
		return xUnit;
	}

	/**
	 * Returns the unit of measure on the Y axis
	 */
	public MeasureUnit getYUnit() {
		return yUnit;
	}
	
	public void setXUnit(MeasureUnit unit) {
		this.xUnit = unit;
	}
	
	public void setYUnit(MeasureUnit unit) {
		this.yUnit = unit;
	}

	public Size getDocumentSize() {
		return documentSize.clone();
	}

	public Point getViewPosition() {
		return viewPosition.clone();
	}
	
	/* (non-Javadoc)
	 * @see ro.pub.cs.stadium.document.IDocument#setViewPosition(ro.pub.cs.stadium.document.Point)
	 */
	public void setViewPosition(Point newPos) {
		viewPosition = newPos.clone();
		
	}

	public float getZoom() {
		return zoom;
	}

	/* (non-Javadoc)
	 * @see ro.pub.cs.stadium.document.IDocument#setZoom(float)
	 */
	public void setZoom(float value) {
		this.zoom = value;
		
	}
	
	
}
